$OpenBSD: patch-mpg321_c,v 1.7 2012/07/13 09:05:38 naddy Exp $
--- mpg321.c.orig	Sun Mar 25 14:27:49 2012
+++ mpg321.c	Sun Jul  8 14:15:18 2012
@@ -332,9 +332,15 @@ void mpg321_error(char *file)
 
 void usage(char *argv0)
 {
+    ao_info **devices;
+    int i, driver_count;
+
+    devices = ao_driver_info_list(&driver_count);
+
     mpg123_boilerplate();
     fprintf(stderr,
-        "\nUsage: %s [options] file(s) | URL(s) | -\n\n"
+        "\nUsage: %s [options] file(s) | URL(s) | -\n\n", argv0);
+    fprintf(stderr,
         "Options supported:\n"
         "   --verbose or -v          Increase verbosity\n"
         "   --quiet or -q            Quiet mode (no title or boilerplate)\n"
@@ -342,7 +348,13 @@ void usage(char *argv0)
         "   --skip N or -k N         Skip N frames into the file\n"
         "   --frames N or -n N       Play only the first N frames\n"
         "   -o dt                    Set output devicetype to dt\n" 
-        "                                [esd,alsa(09),arts,sun,oss]\n"
+        "                                (");
+    for (i = 0; i < driver_count; i++) {
+        fprintf(stderr, "%s%s", devices[i]->short_name,
+            (i + 1 < driver_count) ? ", " : "");
+    }
+    fprintf(stderr,
+        ")\n"
         "   --audiodevice N or -a N  Use N for audio-out\n"
         "   --stdout or -s           Use stdout for audio-out\n"
         "   --au N                   Use au file N for output\n"
@@ -376,7 +388,7 @@ void usage(char *argv0)
 	"n        Skip song.                                    \n"
 	"\n"
         "This version of mpg321 has been configured with " AUDIO_DEFAULT " as its default\n"
-        "libao output device.\n" , argv0);
+        "libao output device.\n");
 }
 
 /* retsigtype is defined by configure;
@@ -539,6 +551,8 @@ int main(int argc, char *argv[])
 
     status = MPG321_PLAYING;
     
+    ao_initialize();
+
     /* Get the command line options */
     parse_options(argc, argv, pl);
 
@@ -666,7 +680,6 @@ int main(int argc, char *argv[])
 
     }
     else {
-	    ao_initialize();
 	    check_default_play_device();
     }
     
@@ -764,6 +777,8 @@ int main(int argc, char *argv[])
         signal(SIGINT, SIG_DFL);
         
         playbuf.buf = NULL;
+        playbuf.frames = NULL;
+        playbuf.times = NULL;
         playbuf.fd = -1;
         playbuf.length = 0;
         playbuf.done = 0;
